package com.gnerv.sylvanas.business.manage.operation;

import com.gnerv.sylvanas.framework.core.BaseCurrentAccount;
import com.gnerv.sylvanas.business.manage.model.bo.ApiGroupBO;
import com.gnerv.sylvanas.business.manage.model.dto.ApiGroupDTO;
import com.gnerv.sylvanas.business.manage.model.dto.ApiGroupTreeDTO;
import com.gnerv.sylvanas.business.manage.model.dto.ApiGroupTreeDetailsDTO;
import com.gnerv.sylvanas.business.manage.model.entity.ApiGroup;
import com.gnerv.sylvanas.business.manage.storage.ApiGroupStorageService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Gnerv LiGen
 */
@Slf4j
@Service
@AllArgsConstructor
public class ApiGroupOperationService {

    private final ApiGroupStorageService apiGroupStorageService;
    private final BaseCurrentAccount baseCurrentAccount;

    
    public boolean create(ApiGroupBO apiGroupBO) {
        ApiGroup apiGroup = apiGroupBO.toApiGroup();
        
        apiGroupStorageService.insert(apiGroup);
        return true;
    }

    
    public boolean deleteByUkId(String ukId) {
        apiGroupStorageService.deleteByUkId(ukId);
        return true;
    }

    
    public boolean updateByUkId(ApiGroupBO apiGroupBO) {
        ApiGroup apiGroup = apiGroupBO.toApiGroup();
        apiGroupStorageService.updateByUkId(apiGroup);
        return true;
    }

    
    public ApiGroupDTO selectByUkId(String ukId) {
        return apiGroupStorageService.selectByUkId(ukId);
    }

    
    public List<ApiGroupDTO> selectListByName(String name, int limitStart, int limitSize) {
        return apiGroupStorageService.selectListByName(name, limitStart, limitSize);
    }

    
    public int selectCountByName(String name) {
        return apiGroupStorageService.selectCountByName(name);
    }

    
    public List<ApiGroupTreeDTO> selectListTreeByParentUkId(String parentUkId) {
        return apiGroupStorageService.selectListTreeByParentUkId(parentUkId);
    }

    
    public List<ApiGroupTreeDetailsDTO> selectListTreeDetailsByParentUkId(String parentUkId) {
        return apiGroupStorageService.selectListTreeDetailsByParentUkId(parentUkId);
    }

}
